<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>2-广告的显示与隐藏</title>
    <style>
        .box{
            width: 300px;
            height: 150px;
            background: url(images/os.png);
			margin-top:20px;
			display:none;
        }
		button{
			padding:4px 8px;
			cursor:pointer;
		}
    </style>
	<!-- 导入jquery库 版本号2.1.4-->
    <script src="js/jquery2.1.4.min.js"></script>
</head>

<body>
    <button>显示</button>
    <button>隐藏</button>
    <button>切换</button>
    <div class="box"></div>
	<script type="text/javascript">
		$(function(){
			//Object { 0: button, length: 1, prevObject: {…}, context: HTMLDocument
			console.log($('button').eq(0));//jquery元素对象
			//显示 show('slow',function(){})
			$('button').eq(0).click(function(){
				//在动画完成时执行的函数
				$('.box').show('slow',function(){
					alert('快来抢购吧');
				});
			});
			//隐藏
			$('button').eq(1).click(function(){
				$('.box').hide('fast',function(){
					alert('来晚了，没了!');
				});
			});
			//切换
			$('button').eq(2).click(function(){
				$('.box').toggle('slow');
			});
		});
	</script>
</body>

</html>
